import React from 'react';
import { connect } from 'react-redux';
import { Button, Form, Input } from 'antd';
import {history} from "umi"
interface Props {}

function Addhouse({dispatch}:any) {
  const onFinish = (values: any) => {
    console.log('Success:', values);
    values.id=new Date().getTime();
    console.log(values.id);
    values.update_time=new Date().getTime()/1000
    dispatch({
        type:"index/ADDHOUSE",
        payload: values
    })
    history.push("/index/Home/Wq")
  };

  const onFinishFailed = (errorInfo: any) => {
    console.log('Failed:', errorInfo);
  };


  return (
    <div>
      <Form
        name="basic"
        labelCol={{ span: 8 }}
        wrapperCol={{ span: 8 }}
        // style={{ maxWidth: 600 }}
        initialValues={{ remember: true }}
        onFinish={onFinish}
        onFinishFailed={onFinishFailed}
        autoComplete="off"
      >
        <Form.Item label="楼盘名称" name="title">
          <Input />
        </Form.Item>
        <Form.Item label="均价" name="price">
          <Input />
        </Form.Item>

        <Form.Item label="楼盘地址" name="address">
          <Input />
        </Form.Item>
        <Form.Item label="售楼处手机号" name="sale_phone">
          <Input />
        </Form.Item>
        <Form.Item label="排名" name="hits">
          <Input />
        </Form.Item>

        <Form.Item wrapperCol={{ offset: 8, span: 8 }}>
          <Button type="primary" htmlType="submit">
            提交
          </Button>
        </Form.Item>
      </Form>
    </div>
  );
}

const mapStateToProps = () => ({});

export default connect(mapStateToProps)(Addhouse);
